﻿/* 加载所有门票、酒店、线路数据 */
var ISS_MAP_SEARCH_START_NAV = {
    Lng: "",
    Lat: "",
    Name: "我的位置"
};

var resultData;
function LoadAll(cnName, pageindex, currentIndex) {
    //标识正在加载
    ISS_MAP.Loading = true;
    $("#buttons-tabs").attr("disabled", "disabled");

    var _search = [];
    var _order = [];
    var url = "";
    if (currentIndex == 0) {
        //名称查询
        if (cnName && cnName != null) {
            _search = [
                {
                    SearchField: "Keyword",
                    ConditionType: 2,
                    AndOR: "and",
                    ListSearchValue: [
                        {
                            ItemValue: cnName
                        }
                    ]
                }];
        }
        //排序
        _order = [
            {
                OrderField: "priceOrder", //排序字段
                OrderType: "asc"
            }
        ];
        //url
        url = ISS_Constants.Url.defaulturl + ISS_Constants.serviceName.ATTAR;
    } else if (currentIndex == 1) {
        //名称查询
        if (cnName && cnName != null) {
            _search = [
                {
                    SearchField: "HotelKey",
                    ConditionType: 2,
                    AndOR: "and",
                    ListSearchValue: [
                        {
                            ItemValue: cnName
                        }
                    ]
                }];
        }
        //排序
        _order = [
            {
                OrderField: "priceOrder", //排序字段
                OrderType: "asc"
            }
        ];
        //url
        url = ISS_Constants.Url.defaulturl + ISS_Constants.serviceName.HOTEL;
    }
    else if (currentIndex == 2) {
        //名称查询
        if (cnName && cnName != null) {
            _search = [
                {
                    SearchField: "CnName",
                    ConditionType: 2,
                    AndOR: "and",
                    ListSearchValue: [
                        {
                            ItemValue: cnName
                        }
                    ]
                }];
        }
        //排序
        _order = [
            {
                OrderField: "expense", //排序字段
                OrderType: "asc"
            }
        ];
        //url
        url = ISS_Constants.Url.defaulturl + ISS_Constants.serviceName.RESTAURANT;
    }

    //JSON
    var _content = JSON.stringify({
        type: 0,
        conditionParams: {
            Page: {
                PageSize: 10000,
                PageIndex: pageindex
            },
            Search: _search,
            Order: _order
        },
        lng: iss_localStorage.get("yuqing_longitude"),
        lat: iss_localStorage.get("yuqing_latitude")
    })

    $$.ajax({
        url: url,
        data: { "content": _content },
        crossDomain: true,
        method: "POST",
        success: function (data, status) {
            //数据转换
            data = JSON.parse(data);
            if (data && data.results && data.results.length > 0) {
                //                if (pageindex == 1) {
                //清除地图覆盖物
                ISS_MAP.ClearArc();
                //                }
                //清除Markers集合
                ISS_MAP.Markers = [];
                //处理数据
                for (var i = 0; i < data.results.length; i++) {
                    //加index(修改后都是从1开始)
                    // data.results[i].Index = (pageindex - 1) * 10 + i + 1;
                    data.results[i].Index = i + 1;
                    //处理距离，小数点后1位
                    var pointIndex = String(data.results[i].distance).lastIndexOf(".");
                    if (pointIndex > 0) {
                        data.results[i].distance = String(data.results[i].distance).substring(0, pointIndex + 2);
                    }
                    //根据星级创建循环对象
                    if (currentIndex == 0) {
                        var startlevel = ISS_MAP_BASEDATA.AttrStartLevel(data.results[i].attractionsStar);
                        data.results[i].starPic = [];
                        for (var starcount = 0; starcount < startlevel.value; starcount++) {
                            data.results[i].starPic.push("1");
                        }
                        data.results[i].starB = startlevel.text;
                    } else if (currentIndex == 1) {
                        var startlevel = ISS_MAP_BASEDATA.HotelStartLevel(data.results[i].hotelStart);
                        data.results[i].starPic = [];
                        for (var starcount = 0; starcount < startlevel.value; starcount++) {
                            data.results[i].starPic.push("1");
                        }
                        data.results[i].starB = startlevel.text;
                    }
                    //价格
                    if (currentIndex == 0 || currentIndex == 1) {
                        if (parseFloat(data.results[i].minSalePrice) == 0) {
                            data.results[i].minSalePrice = "免费";
                        } else {
                            data.results[i].minSalePrice = "￥" + data.results[i].minSalePrice;
                        }
                    } else if (currentIndex == 2) {
                        if (parseFloat(data.results[i].expense) == 0) {
                            data.results[i].expense = "免费";
                        } else {
                            data.results[i].expense = "￥" + data.results[i].expense;
                        }
                    }
                    //绘点
                    ISS_MAP.DrawArc(data.results[i].longitude, data.results[i].latitude, currentIndex + 1, data.results[i].Index);
                }
                //绑定template7
                if (currentIndex == 0) {
                    var searchTemplate = $$("#template_Ticket").html();
                    if (searchTemplate) {
                        var compiledTemplate = Template7.compile(searchTemplate);
                        var html = compiledTemplate(data);
                        //                        if (pageindex == 1) {
                        //                            //清除内容
                        //                            $$("#tab_Ticket .content-block").html("");
                        //                        }

                        //清除内容(修改，每次都清空）
                        $$("#tab_Ticket .content-block").html("");
                        $$("#tab_Ticket .content-block").append(html);
                    }
                }
                else if (currentIndex == 1) {
                    var searchTemplate = $$("#template_Hotel").html();
                    if (searchTemplate) {
                        var compiledTemplate = Template7.compile(searchTemplate);
                        var html = compiledTemplate(data);
                        //                        if (pageindex == 1) {
                        //                            //清除内容
                        //                            $$("#tab_Hotel .content-block").html("");
                        //                        }

                        //清除内容(修改，每次都清空）
                        $$("#tab_Hotel .content-block").html("");
                        $$("#tab_Hotel .content-block").append(html);
                    }
                }
                else if (currentIndex == 2) {
                    var searchTemplate = $$("#template_Rest").html();
                    if (searchTemplate) {
                        var compiledTemplate = Template7.compile(searchTemplate);
                        var html = compiledTemplate(data);
                        //                        if (pageindex == 1) {
                        //                            //清除内容
                        //                            $$("#tab_Rest .content-block").html("");
                        //                        }

                        //清除内容(修改，每次都清空）
                        $$("#tab_Rest .content-block").html("");
                        $$("#tab_Rest .content-block").append(html);
                    }
                }

                //置顶
                $$('.infinite-scroll').scrollTop(0);

                //加载无限滚动事件
                myApp.attachInfiniteScroll($$('.infinite-scroll'));

                //tab1综合,无限滚动只加载一次
                if (!ISS_MAP.sroll.flag_execute) {
                    //只执行一次
                    ISS_MAP.sroll.flag_execute = true;
                    // 加载flag
                    var loading = false;
                    $$('.infinite-scroll').on('infinite', function (e) {
                        //切换
                        if (!ISS_MAP.sroll.flag_needScroll) {
                            ISS_MAP.sroll.flag_needScroll = true;
                            return;
                        }
                        //查询时,删除滚动后重新绑定pageindex
                        if (!ISS_MAP.sroll.flag_InfiniteScroll) {
                            ISS_MAP.sroll.flag_InfiniteScroll = true;
                            return;
                        }
                        if (true) {
                            // 如果正在加载，则退出
                            if (loading) return;
                            // 设置flag
                            loading = true;
                            // 模拟1s的加载过程
                            setTimeout(function () {
                                // 重置加载flag
                                loading = false;
                                if (ISS_MAP.sroll.current_tabindex == 0) {
                                    ISS_MAP.sroll.index_tab0++;
                                    LoadAll(ISS_MAP.Keyword, ISS_MAP.sroll.index_tab0, ISS_MAP.sroll.current_tabindex);
                                }
                                else if (ISS_MAP.sroll.current_tabindex == 1) {
                                    ISS_MAP.sroll.index_tab1++;
                                    LoadAll(ISS_MAP.Keyword, ISS_MAP.sroll.index_tab1, ISS_MAP.sroll.current_tabindex);
                                }
                                else if (ISS_MAP.sroll.current_tabindex == 2) {
                                    ISS_MAP.sroll.index_tab2++;
                                    LoadAll(ISS_MAP.Keyword, ISS_MAP.sroll.index_tab2, ISS_MAP.sroll.current_tabindex);
                                }
                            }, 100);
                        }
                    });
                }

                if (currentIndex == 0 && $$("#tab_Ticket .content-block .mapcontent").length >= parseInt(data.total)) {
                    // 删除加载提示符
                    $$('.infinite-scroll-preloaderTicket').hide();
                    // 加载完毕，则注销无限加载事件，以防不必要的加载
                    myApp.detachInfiniteScroll($$('.infinite-scroll'));
                }
                else if (currentIndex == 1 && $$("#tab_Hotel .content-block .mapcontent").length >= parseInt(data.total)) {
                    // 删除加载提示符
                    $$('.infinite-scroll-preloaderHotel').hide();
                    // 加载完毕，则注销无限加载事件，以防不必要的加载
                    myApp.detachInfiniteScroll($$('.infinite-scroll'));
                }
                else if (currentIndex == 2 && $$("#tab_Rest .content-block .mapcontent").length >= parseInt(data.total)) {
                    // 删除加载提示符
                    $$('.infinite-scroll-preloaderRest').hide();
                    // 加载完毕，则注销无限加载事件，以防不必要的加载
                    myApp.detachInfiniteScroll($$('.infinite-scroll'));
                }

                // debugger;
                //最后模拟点击第一行
                if (currentIndex == 0) {
                    if ($("#tab_Ticket .mapcontent").length > 0) {
                        $("#tab_Ticket .mapcontent")[0].click();
                    }
                } else if (currentIndex == 1) {
                    if ($("#tab_Hotel .mapcontent").length > 0) {
                        $("#tab_Hotel .mapcontent")[0].click();
                    }
                } else if (currentIndex == 2) {
                    if ($("#tab_Rest .mapcontent").length > 0) {
                        $("#tab_Rest .mapcontent")[0].click();
                    }
                }
                onNavigationMapTap();
            }
            else {
                //清除地图覆盖物
                ISS_MAP.ClearArc();
                //清空内容
                if (currentIndex == 0) {
                    $$("#tab_Ticket .content-block").html("");
                } else if (currentIndex == 1) {
                    $$("#tab_Hotel .content-block").html("");
                } else if (currentIndex == 2) {
                    $$("#tab_Rest .content-block").html("");
                }
                // 删除加载提示符
                myApp.detachInfiniteScroll($$('.infinite-scroll'));
                if (ISS_MAP.sroll.current_tabindex == 0) {
                    $$('.infinite-scroll-preloaderTicket').hide();
                    if ($$("#tab_Ticket .content-block .mapcontent").length <= 0) {
                        $$("#tab_Ticket .content-block").html(ISS_Element.DIV.noAnswer);
                    }
                }
                else if (ISS_MAP.sroll.current_tabindex == 1) {
                    $$('.infinitesa-scroll-preloaderHotel').hide();
                    if ($$("#tab_Hotel .content-block .mapcontent").length <= 0) {
                        $$("#tab_Hotel .content-block").html(ISS_Element.DIV.noAnswer);
                    }
                }
                else if (ISS_MAP.sroll.current_tabindex == 2) {
                    $$('.infinite-scroll-preloaderRest').hide();
                    if ($$("#tab_Rest .content-block .mapcontent").length <= 0) {
                        $$("#tab_Rest .content-block").html(ISS_Element.DIV.noAnswer);
                    }
                }
            }
            //标识正在加载-完成
            ISS_MAP.Loading = false;
            $("#buttons-tabs").removeAttr("disabled");
        },
        error: function (xhr, status) {
            //错误
            //标识正在加载-完成
            ISS_MAP.Loading = false;
            $("#buttons-tabs").removeAttr("disabled");
        }
    });
}

// 定位对象
function LocalGeocoder() {
    var geoc = new BMap.Geocoder();
    var geolocation = new BMap.Geolocation();
    if (iss_localStorage.get("yuquan_longitude") == "" || iss_localStorage.get("yuquan_latitude") == "" || (time - oldtime) > 5 * 60 * 1000) {

        geolocation.getCurrentPosition(function (r) {
            console.log('定位');
            if (this.getStatus() == BMAP_STATUS_SUCCESS) {
                var icon = new BMap.Icon("../../assets/images/map/position-icon.png", new BMap.Size(14, 14));
                var mark = new BMap.Marker(r.point, { icon: icon });
                ISS_MAP.nearByMap.addOverlay(mark);
                ISS_MAP.nearByMap.centerAndZoom(r.point, 15);
                //定位成功方法
                iss_localStorage.set("yuqing_longitude", r.point.lng);
                iss_localStorage.set("yuqing_latitude", r.point.lat);
                LoadAll("", ISS_MAP.sroll.index_tab0, ISS_MAP.sroll.current_tabindex);

                ISS_MAP_SEARCH_START_NAV.Lat = r.point.lat;
                ISS_MAP_SEARCH_START_NAV.Lng = r.point.lng;

            } else {
                // 定位失败事件
                LoadAll("", ISS_MAP.sroll.index_tab0, ISS_MAP.sroll.current_tabindex);
            }
        }, { enableHighAccuracy: true });
    } else {
        LoadAll("", ISS_MAP.sroll.index_tab0, ISS_MAP.sroll.current_tabindex);

        ISS_MAP_SEARCH_START_NAV.Lat = iss_localStorage.get("yuquan_latitude");
        ISS_MAP_SEARCH_START_NAV.Lng = iss_localStorage.get("yuquan_longitude");
    }
}



// 定位对象
function LocalGeocoder_yuqing() {
    var flag = true;
    var geoc = new BMap.Geocoder();
    var geolocation = new BMap.Geolocation();
    $$('.preloader-bg').show();
    geolocation.getCurrentPosition(function (r) {
        console.log('定位');
        flag = false;
        if (this.getStatus() == BMAP_STATUS_SUCCESS) {
            var icon = new BMap.Icon("../../assets/images/map/position-icon.png", new BMap.Size(14, 14));
            var mark = new BMap.Marker(r.point, { icon: icon });
            ISS_MAP.nearByMap.addOverlay(mark);
            // ISS_MAP.nearByMap.centerAndZoom(r.point, 15);
            //定位成功方法
            iss_localStorage.set("yuqing_longitude", r.point.lng);
            iss_localStorage.set("yuqing_latitude", r.point.lat);
            if (ISS_MAP.sroll.current_tabindex != -1) {
                LoadAll_yuqing("", 1, ISS_MAP.sroll.current_tabindex);
            }

            ISS_MAP_SEARCH_START_NAV.Lat = r.point.lat;
            ISS_MAP_SEARCH_START_NAV.Lng = r.point.lng;

        } else {
            // 定位失败事件
            if (ISS_MAP.sroll.current_tabindex != -1) {
                LoadAll_yuqing("", 1, ISS_MAP.sroll.current_tabindex);
            }
        }
    }, { enableHighAccuracy: true });
}

function LoadAll_yuqing(cnName, pageindex, currentIndex) {

    $('.button').removeClass("active");
    $('.button').eq(currentIndex).addClass("active");

    //标识正在加载
    ISS_MAP.Loading = true;
    $$('.preloader-bg').show();
    var points = [];
    //厕所
    if (currentIndex == 5) {
        var result = toilet_list;
        resultData = [];
        for (var i = 0; i < result.length; i++) {
            if (result[i].cnName.indexOf(cnName) > -1) {
                resultData.push(result[i]);
            }
        }

        //清除地图覆盖物
        ISS_MAP.ClearArc();
        //                }
        //清除Markers集合
        ISS_MAP.Markers = [];
        ISS_MAP.Points = [];

        // //绑定template7
        var viewport = ISS_MAP.nearByMap.getViewport(ISS_MAP.Points);
        ISS_MAP.nearByMap.setCenter(new BMap.Point(resultData[0].Longitude, resultData[0].Latitude));
        ISS_MAP.nearByMap.setZoom(16);

        var bs = ISS_MAP.nearByMap.getBounds();
        var bssw = bs.getSouthWest();   //可视区域左下角
        var bsne = bs.getNorthEast();   //可视区域右上角
        console.log(bssw, bsne);
        var index = 0;
        for (var i = 0; i < resultData.length; i++) {
            if (resultData[i].Longitude >= bssw.lng && resultData[i].Longitude <= bsne.lng && resultData[i].Latitude >= bssw.lat && resultData[i].Latitude <= bsne.lat) {
                ISS_MAP.DrawArc(resultData[i].Longitude, resultData[i].Latitude, resultData[i], currentIndex, index++);
                console.log(i);
            }
        }

        ISS_MAP.nearByMap.addEventListener("dragend", onTouch, false);
        ISS_MAP.nearByMap.addEventListener("zoomend", onTouch, false);

        $$('.preloader-bg').hide();

        return;
    }


    var _search = [];
    var _order = [];
    var url = "";
    if (currentIndex == 0) {
        //名称查询
        if (cnName && cnName != null) {
            _search = [
                {
                    SearchName: "名称",
                    SearchField: "Keyword",
                    ConditionType: 1,
                    AndOR: "and",
                    ListSearchValue: [
                        {
                            ItemValue: cnName
                        }
                    ]
                }];
        }
        //排序
        _order = [
            {
                OrderField: "priceOrder", //排序字段
                OrderType: "desc"
            }
        ];
        //url
        url = ISS_Constants.Url.defaulturl + ISS_Constants.serviceName.ATTAR;
    } else if (currentIndex == 1) {
        //名称查询
        if (cnName && cnName != null) {
            _search = [
                {
                    SearchName: "名称",
                    SearchField: "HotelKey",
                    ConditionType: 1,
                    AndOR: "and",
                    ListSearchValue: [
                        {
                            ItemValue: cnName
                        }
                    ]
                }];
        }
        //排序
        _order = [
            {
                OrderField: "priceOrder", //排序字段
                OrderType: "desc"
            }
        ];
        //url
        url = ISS_Constants.Url.defaulturl + ISS_Constants.serviceName.HOTEL;
    }
    else if (currentIndex == 2) {
        //名称查询
        if (cnName && cnName != null) {
            _search = [
                {
                    SearchName: "名称",
                    SearchField: "CnName",
                    ConditionType: 1,
                    AndOR: "and",
                    ListSearchValue: [
                        {
                            ItemValue: cnName
                        }
                    ]
                }];
        }
        //排序
        _order = [
            {
                OrderField: "expense", //排序字段
                OrderType: "desc"
            }
        ];
        //url
        url = ISS_Constants.Url.defaulturl + ISS_Constants.serviceName.RESTAURANT;
    }
    else if (currentIndex == 3) {
        //名称查询
        if (cnName && cnName != null) {
            _search = [
                {
                    SearchName: "名称",
                    SearchField: "CnName",
                    ConditionType: 1,
                    AndOR: "and",
                    ListSearchValue: [
                        {
                            ItemValue: cnName
                        }
                    ]
                }];
        }
        //排序
        _order = [
            {
                OrderField: "expense", //排序字段
                OrderType: "desc"
            }
        ];
        //url
        // url = "http://119.10.53.45:8090/datacent/external/execute.jhtml?system=CT&serviceName=" + ISS_Constants.serviceName.WEB_ENTERTAINMEN;
        url = ISS_Constants.Url.defaulturl + ISS_Constants.serviceName.WEB_ENTERTAINMEN;
    }
    else if (currentIndex == 4) {
        //名称查询
        if (cnName && cnName != null) {
            _search = [
                {
                    SearchField: "CnName",
                    ConditionType: 2,
                    AndOR: "and",
                    ListSearchValue: [
                        {
                            ItemValue: cnName
                        }
                    ]
                }];
        }
        //排序
        _order = [
            {
                OrderField: "expense", //排序字段
                OrderType: "desc"
            }
        ];
        //url
        // url = "http://119.10.53.45:8090/datacent/external/execute.jhtml?system=CT&serviceName=" + ISS_Constants.serviceName.WEB_ENTERTAINMEN;
        url = "http://121.18.47.197:8072/services/ServiceEngine.ashx?action=device&areaid=&method=getallparking&callback=a";
        // url = "http://10.28.50.77:1405/services/ServiceEngine.ashx";


    }


    var _content;
    if (currentIndex == 4) {

        conditionParams = "";


    } else {

        _content = JSON.stringify({
            type: 0,
            conditionParams: {
                Page: {
                    PageSize: 10000,
                    PageIndex: pageindex
                },
                Search: _search,
                Order: _order
            },
            lng: iss_localStorage.get("yuqing_longitude"),
            lat: iss_localStorage.get("yuqing_latitude")
        })

        conditionParams = {
            content: _content,
        }


    }

    //JSON


    $$.ajax({
        url: url,
        // data: { "content": _content },
        data: conditionParams,
        crossDomain: true,
        method: "POST",
        success: function (data, status) {
            //数据转换

            //停车场
            if (currentIndex == 4) {
                resultData = data.toString();
                resultData = resultData.substring(2, resultData.length - 2);
                resultData = JSON.parse(resultData);

                if (resultData && resultData.Status == 0 && resultData.Data.length > 0) {

                    //清除地图覆盖物
                    ISS_MAP.ClearArc();
                    //                }
                    //清除Markers集合
                    ISS_MAP.Markers = [];
                    ISS_MAP.Points = [];
                    //处理数据
                    var viewport = ISS_MAP.nearByMap.getViewport(ISS_MAP.Points);
                    ISS_MAP.nearByMap.setCenter(new BMap.Point(resultData.Data[0].X, resultData.Data[0].Y));
                    ISS_MAP.nearByMap.setZoom(16);

                    var bs = ISS_MAP.nearByMap.getBounds();
                    var bssw = bs.getSouthWest();   //可视区域左下角
                    var bsne = bs.getNorthEast();   //可视区域右上角
                    console.log(bssw, bsne);
                    var index = 0;
                    for (var i = 0; i < resultData.Data.length; i++) {

                        resultData.Data[i].Index = i + 1;
                        //处理距离，小数点后1位

                        if (resultData.Data[i].X >= bssw.lng && resultData.Data[i].X <= bsne.lng && resultData.Data[i].Y >= bssw.lat && resultData.Data[i].Y <= bsne.lat) {
                            ISS_MAP.DrawArc(resultData.Data[i].X, resultData.Data[i].Y, resultData.Data[i], currentIndex, index++);
                            console.log(i);
                        }
                        // //绘点
                        // ISS_MAP.DrawArc(data.Data[i].X, data.Data[i].Y, data.Data[i], currentIndex, i);
                    }

                    ISS_MAP.nearByMap.addEventListener("dragend", onTouch, false);
                    ISS_MAP.nearByMap.addEventListener("zoomend", onTouch, false);

                    //置顶
                    $$('.infinite-scroll').scrollTop(0);

                    //加载无限滚动事件
                    myApp.attachInfiniteScroll($$('.infinite-scroll'));




                }
                else {

                    //清除地图覆盖物
                    ISS_MAP.ClearArc();
                    // 删除加载提示符
                    myApp.detachInfiniteScroll($$('.infinite-scroll'));

                }
                //标识正在加载-完成
                ISS_MAP.Loading = false;
                $("#buttons-tabs").removeAttr("disabled");

                $$('.preloader-bg').hide();


                return;
            }

            resultData = JSON.parse(data);
            if (resultData && resultData.results && resultData.results.length > 0) {
                //                if (pageindex == 1) {
                //清除地图覆盖物
                ISS_MAP.ClearArc();
                //                }
                //清除Markers集合
                ISS_MAP.Markers = [];
                ISS_MAP.Points = [];
                //处理数据
                for (var i = 0; i < resultData.results.length; i++) {
                    if (resultData.results[i].longitude == 0 || resultData.results[i].latitude == 0) {
                        resultData.results.splice(i, 1);
                    }
                }
                var viewport = ISS_MAP.nearByMap.getViewport(ISS_MAP.Points);
                ISS_MAP.nearByMap.setCenter(new BMap.Point(resultData.results[0].longitude, resultData.results[0].latitude));
                ISS_MAP.nearByMap.setZoom(16);

                var bs = ISS_MAP.nearByMap.getBounds();
                var bssw = bs.getSouthWest();   //可视区域左下角
                var bsne = bs.getNorthEast();   //可视区域右上角
                console.log(bssw, bsne);
                var index = 0;
                for (var i = 0; i < resultData.results.length; i++) {

                    resultData.results[i].Index = i + 1;
                    //处理距离，小数点后1位
                    var pointIndex = String(resultData.results[i].distance).lastIndexOf(".");
                    if (pointIndex > 0) {
                        resultData.results[i].distance = String(resultData.results[i].distance).substring(0, pointIndex + 2);
                    }

                    if (resultData.results[i].longitude >= bssw.lng && resultData.results[i].longitude <= bsne.lng && resultData.results[i].latitude >= bssw.lat && resultData.results[i].latitude <= bsne.lat) {
                        ISS_MAP.DrawArc(resultData.results[i].longitude, resultData.results[i].latitude, resultData.results[i], currentIndex, index++);
                        console.log(i);
                    }

                    // //绘点
                    // ISS_MAP.DrawArc(data.results[i].longitude, data.results[i].latitude, data.results[i], currentIndex, i);
                }

                ISS_MAP.nearByMap.addEventListener("dragend", onTouch, false);
                ISS_MAP.nearByMap.addEventListener("zoomend", onTouch, false);

                //置顶
                $$('.infinite-scroll').scrollTop(0);

                //加载无限滚动事件
                myApp.attachInfiniteScroll($$('.infinite-scroll'));




            }
            else {
                //清除地图覆盖物
                ISS_MAP.ClearArc();

                // 删除加载提示符
                myApp.detachInfiniteScroll($$('.infinite-scroll'));

            }
            //标识正在加载-完成
            ISS_MAP.Loading = false;
            $("#buttons-tabs").removeAttr("disabled");
            $$('.preloader-bg').hide();
        },
        error: function (xhr, status) {
            //错误
            //标识正在加载-完成
            ISS_MAP.Loading = false;
            $("#buttons-tabs").removeAttr("disabled");
            $$('.preloader-bg').hide();
        }
    });


}

function onTouch() {
    if (ISS_MAP.sroll.current_tabindex != -1) {
        ISS_MAP.ClearArc();
        var bs = ISS_MAP.nearByMap.getBounds();
        var bssw = bs.getSouthWest();   //可视区域左下角
        var bsne = bs.getNorthEast();   //可视区域右上角
        console.log(bssw, bsne);
        var index = 0;
        if (ISS_MAP.sroll.current_tabindex == 5) {
            for (var i = 0; i < resultData.length; i++) {
                if (resultData[i].Longitude >= bssw.lng && resultData[i].Longitude <= bsne.lng && resultData[i].Latitude >= bssw.lat && resultData[i].Latitude <= bsne.lat) {
                    ISS_MAP.DrawArc(resultData[i].Longitude, resultData[i].Latitude, resultData[i], ISS_MAP.sroll.current_tabindex, index++);
                    console.log(i);
                }
            }
        } else if (ISS_MAP.sroll.current_tabindex == 4) {
            for (var i = 0; i < resultData.Data.length; i++) {
                if (resultData.Data[i].X >= bssw.lng && resultData.Data[i].X <= bsne.lng && resultData.Data[i].Y >= bssw.lat && resultData.Data[i].Y <= bsne.lat) {
                    ISS_MAP.DrawArc(resultData.Data[i].X, resultData.Data[i].Y, resultData.Data[i], ISS_MAP.sroll.current_tabindex, index++);
                    console.log(i);
                }
                // //绘点
                // ISS_MAP.DrawArc(data.Data[i].X, data.Data[i].Y, data.Data[i], currentIndex, i);
            }
        } else {
            for (var i = 0; i < resultData.results.length; i++) {
                if (resultData.results[i].longitude >= bssw.lng && resultData.results[i].longitude <= bsne.lng && resultData.results[i].latitude >= bssw.lat && resultData.results[i].latitude <= bsne.lat) {
                    ISS_MAP.DrawArc(resultData.results[i].longitude, resultData.results[i].latitude, resultData.results[i], ISS_MAP.sroll.current_tabindex, index++);
                    console.log(i);
                }
            }
        }
    }
}

var toilet_list = [
    {
        "cnName": "野三坡服务区公共厕所",
        "address": "河北省保定市涞水县g108",
        "Longitude": "115.423835",
        "Latitude": "39.744191",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "野三坡大街118号附近",
        "Longitude": "115.460285",
        "Latitude": "39.67777",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区百里峡景区内",
        "Longitude": "115.39278",
        "Latitude": "39.679586",
        "distance": ""
    },
    {
        "cnName": "野三坡百草畔森林公园公共厕所",
        "address": "九龙镇北边桥村白草畔景区内",
        "Longitude": "115.546963",
        "Latitude": "39.815821",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "野三坡民族园附近",
        "Longitude": "115.468335",
        "Latitude": "39.67229",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "野三坡国家地质公园附近",
        "Longitude": "115.391978",
        "Latitude": "39.675463",
        "distance": ""
    },
    {
        "cnName": "野三坡服务区公厕",
        "address": "保定市涞水县",
        "Longitude": "115.42387",
        "Latitude": "39.743967",
        "distance": ""
    },
    {
        "cnName": "野三坡服务区公厕",
        "address": "保定市涞水县",
        "Longitude": "115.427092",
        "Latitude": "39.74426",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡龙门天关景区附近上天沟聚神瀑内",
        "Longitude": "115.363509",
        "Latitude": "39.836158",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇野三坡园区中部鱼谷洞景区内",
        "Longitude": "115.420678",
        "Latitude": "39.768586",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区拒马河景区野三坡大峡谷内",
        "Longitude": "115.472088",
        "Latitude": "39.698597",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区百里峡景区内",
        "Longitude": "115.411537",
        "Latitude": "39.664971",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区百里峡景区内",
        "Longitude": "115.409072",
        "Latitude": "39.668175",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区百里峡景区内",
        "Longitude": "115.405728",
        "Latitude": "39.669597",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区百里峡景区内",
        "Longitude": "115.407761",
        "Latitude": "39.663538",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区百里峡景区内",
        "Longitude": "115.411578",
        "Latitude": "39.665289",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区百里峡景区内",
        "Longitude": "115.396362",
        "Latitude": "39.672946",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区百里峡景区内",
        "Longitude": "115.393406",
        "Latitude": "39.679095",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区拒马河景区内",
        "Longitude": "115.448482",
        "Latitude": "39.703167",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区百里峡景区内",
        "Longitude": "115.409521",
        "Latitude": "39.663808",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区百里峡景区内",
        "Longitude": "115.403296",
        "Latitude": "39.674083",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区百里峡景区内",
        "Longitude": "115.412576",
        "Latitude": "39.666997",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区百里峡景区内",
        "Longitude": "115.403225",
        "Latitude": "39.662774",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区百里峡景区内",
        "Longitude": "115.393094",
        "Latitude": "39.673994",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区百里峡景区内",
        "Longitude": "115.392337",
        "Latitude": "39.676395",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇野三坡园区中部鱼谷洞景区内",
        "Longitude": "115.420131",
        "Latitude": "39.767432",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇野三坡园区中部鱼谷洞景区鱼谷泉内",
        "Longitude": "115.418037",
        "Latitude": "39.764779",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区拒马河景区中国·野三坡品道创意运动休闲基地内",
        "Longitude": "115.424693",
        "Latitude": "39.689844",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区百里峡景区内",
        "Longitude": "115.404088",
        "Latitude": "39.664503",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区百里峡景区内",
        "Longitude": "115.407294",
        "Latitude": "39.672328",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区百里峡景区内",
        "Longitude": "115.40415",
        "Latitude": "39.672042",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇苟各庄村野三坡园区百里峡景区内",
        "Longitude": "115.40718",
        "Latitude": "39.663268",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "野三坡镇苟各庄村野三坡百里峡景区",
        "Longitude": "115.391716",
        "Latitude": "39.675623",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县太行山与燕山交汇处龙门天关景区上天沟内",
        "Longitude": "115.359405",
        "Latitude": "39.836767",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县太行山与燕山交汇处龙门天关景区内",
        "Longitude": "115.371146",
        "Latitude": "39.834455",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇野三坡园区中部鱼谷洞景区内",
        "Longitude": "115.420678",
        "Latitude": "39.768586",
        "distance": ""
    },
    {
        "cnName": "公共厕所",
        "address": "保定市涞水县野三坡镇野三坡园区中部鱼谷洞景区内",
        "Longitude": "115.420131",
        "Latitude": "39.767432",
        "distance": ""
    }
];